﻿@model List<CMP.ERP.Model.Shipments>
@{
    Layout = null;
}
@Html.Action("Account_Show", "Account");
<div class="content">
    <div class="right" id="mainFrame">
        <div class="right_cont">
            <!-- 顶部 -->
            <div id="middle">
                <div class="Switch"></div>
                <script type="text/javascript">
                        $(document).ready(function (e) {
                            $(".Switch").click(function () {
                                $(".left").toggle();

                            });
                        });
                </script>
                <div class="right" id="mainFrame">

                    <div class="right_cont">
                        当前位置：
                        <a href="/Home/Index">首页</a>
                        <span class="divider">/</span>
                        订单报表
                        <div style="width:100%; margin:auto">
                            <div>
                                <table>
                                    <tr>
                                        <td>
                                            <select id="Select1" style="width:60px;">
                                                <option value="年">年</option>
                                                <option value="月">月</option>
                                                <option value="日">日</option>
                                            </select>
                                        </td>
                                        <td>下单时间:</td>
                                        <td>从:</td>
                                        <td><input type="text" name="StartTime" style="width:100px;" /></td>
                                        <td>至:</td>
                                        <td><input type="text" name="End_Time" style="width:100px;" /></td>
                                        <td><button type="button" class="btn btn-default" onclick="Sel()" style="margin-bottom:10px"><span class="icon-search"></span>查询 </button></td>
                                    </tr>
                                </table>
                            </div>
                            <div style="margin-top:20px;">
                                <table class="table  table-hover table-bordered table-striped" id="OrderReport">
                                    <thead>
                                        <tr>
                                            <th>下单时间</th>
                                            <th>总金额(元)</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function Sel() {
        var Start=$("[name=StartTime]").val();
        var End=$("[name=End_Time]").val();
        var aa = $("#Select1").val();
        $("#OrderReport tbody").html("");
        //循环取每年总金额
        if (Start != "" && End!="")
        {
                if (aa == "年") {
                    $.ajax({
                        url: "/OrderReport/SelYear",
                        type: "get",
                        cache: false,
                        data: {
                            StartTime: Start,
                            End_Time: End
                        },
                        success: function (data) {
                            $(data).each(function (index, item) {
                                var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                                $("#OrderReport tbody").append(apen);
                            });
                        }
                    });
                }
                else if (aa == "月") {
                    $.ajax({
                        url: "/OrderReport/SelMonth",
                        type: "post",
                        data: {
                            StartTime: Start,
                            End_Time: End
                        },
                        success: function (data) {
                            $(data).each(function (index, item) {
                                var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                                $("#OrderReport tbody").append(apen);
                            });
                        }
                    });
                }
                else if (aa == "日") {
                    $.ajax({
                        url: "/OrderReport/SelDay",
                        type: "post",
                        data: {
                            StartTime: Start,
                            End_Time: End
                        },
                        success: function (data) {
                            $(data).each(function (index, item) {
                                var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                                $("#OrderReport tbody").append(apen);
                            });
                        }
                    });
                }
        }
        else if (Start == "")
        {
            Start = End;
            if (aa == "年") {
                $.ajax({
                    url: "/OrderReport/SelYear",
                    type: "get",
                    cache: false,
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
            else if (aa == "月") {
                $.ajax({
                    url: "/OrderReport/SelMonth",
                    type: "post",
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
            else if (aa == "日") {
                $.ajax({
                    url: "/OrderReport/SelDay",
                    type: "post",
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
        }
        else
        {
            End = Start;
            if (aa == "年") {
                $.ajax({
                    url: "/OrderReport/SelYear",
                    type: "get",
                    cache: false,
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
            else if (aa == "月") {
                $.ajax({
                    url: "/OrderReport/SelMonth",
                    type: "post",
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
            else if (aa == "日") {
                $.ajax({
                    url: "/OrderReport/SelDay",
                    type: "post",
                    data: {
                        StartTime: Start,
                        End_Time: End
                    },
                    success: function (data) {
                        $(data).each(function (index, item) {
                            var apen = "<tr><td>" + item.Tdate + "" + aa + "</td><td>" + item.Num + "</td></tr>";
                            $("#OrderReport tbody").append(apen);
                        });
                    }
                });
            }
        }
    };
</script>